package com.huat.controller;


import com.huat.pojo.UserInfo;
import com.huat.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
public class UserInfoController {

    @Autowired
    UserInfoService userInfoService;
    @Autowired
    UserInfo userInfo;
    @RequestMapping("/userinfo/submit")
    public String submitUserInfo(@RequestParam("q1")String q1, @RequestParam("q2")String q2, @RequestParam("q3")String q3, @RequestParam("q4")String q4,@RequestParam("q5")String q5, @RequestParam("q6")String q6, @RequestParam("q7")String q7, @RequestParam("q8")String q8, @RequestParam("q9")String q9, @RequestParam("q10")String q10, @RequestParam("q11")String q11, @RequestParam("q12")String q12, @RequestParam("q13")String q13, @RequestParam("userid")String userid, HttpSession session){
        if (q2.equals("37.2℃及以下")){
            userInfo.setQ1(q1);
            userInfo.setQ2(q2);
            userInfo.setQ3(q3);
            userInfo.setQ4(q4);
            userInfo.setUserid(Integer.parseInt(userid));
        }else{
            userInfo.setQ1(q1);
            userInfo.setQ2(q2);
            userInfo.setQ3(q3);
            userInfo.setQ4(q4);
            userInfo.setQ5(q5);
            userInfo.setQ6(q6);
            userInfo.setQ7(q7);
            userInfo.setQ8(q8);
            userInfo.setQ9(q9);
            userInfo.setQ10(q10);
            userInfo.setQ11(q11);
            userInfo.setQ12(q12);
            userInfo.setQ13(q13);
            userInfo.setUserid(Integer.parseInt(userid));
        }
        userInfoService.submit(userInfo);
        return "/login.html";
    }
}
